<?php $this->load->view('admin/public/head.html', array('css' => array(
'/assets/admin/css/admin/common.css'
))); ?>
<script>
    var initBaseId = 0;
</script>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper orderIndexAdmin" ng-controller="admin-order-index-controller">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            订单管理
            <small>查看订单状态</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i>后台首页</a></li>
            <li class="active">会员列表</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li ng-class="{'active': page.status == ''}" ng-click="select('')"><a href="#activity"
                                                                                              data-toggle="tab">全部订单</a>
                        </li>
                        <li ng-repeat="s in selects.allStatus"
                            ng-click="select(s.key)"
                            ng-class="{active: page.status !== '' && page.status == s.key}">
                            <a href="javascript:;" ng-bind="s.value"></a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="active tab-pane" id="activity">
                            <div class="box">
                                <!-- /.box-header -->
                                <div class="box-body">
                                    <table class="table table-bordered order-lists">
                                        <tr>
                                            <th class="text-center" style="width: 40px">#</th>
                                            <th style="width: 140px;" class="text-center">订单号</th>
                                            <th class="text-center">用户昵称</th>
                                            <th style="" class="text-center">支付金额</th>
                                            <th style="" class="text-center">商品金额</th>
                                            <th style="" class="text-center">物流费用</th>
                                            <th class="text-center" style="width: 150px;">下单时间</th>
                                            <th class="text-center">支付方式</th>
                                            <th class="text-center">订单状态</th>
                                            <th class="text-center" style="width: 130px">查看</th>
                                        </tr>
                                        <tr ng-repeat="(key, list) in lists">
                                            <td class="text-center" ng-bind="list.id"></td>
                                            <td class="text-center"><a href="javascript:;"  ng-click="alertModal(list.id)" ng-bind="list.sn"></a></td>
                                            <td class="text-center">
                                                <a href="/user/detail/index?id={{ list.userId }}" ng-bind="list.nickName"></a>
                                            </td>
                                            <td class="text-red text-center" ng-bind="'￥' + list.totalPrice"></td>
                                            <td class="text-red text-center" ng-bind="'￥' + list.goodsPrice"></td>
                                            <td class="text-red text-center" ng-bind="'￥' + list.expressPrice"></td>
                                            <td class="text-center" ng-bind="list.created"></td>

                                            <td class="text-center">
                                                <span ng-class="{'text-green': list.payMode == 'online', 'text-red': list.payMode=='delivery'}" ng-bind="list.payMode == 'online' ? '在线支付' : '货到付款'"></span>
                                            </td>
                                            <td class="text-center">
                                                <span class="badge"
                                                      ng-class="{
                                                      'bg-green': list.status == 'Complete',
                                                      'bg-aqua': list.status == 'Dispatch',
                                                      'bg-light': list.status == 'Pendding',
                                                      'bg-yellow': list.status == 'Unpaid',
                                                      'bg-red': list.status == 'Returns' || list.status == 'Refund',
                                                      'bg-maroon': list.status == 'Refunded'
                                                      }"
                                                      ng-bind="list.formatStatus"></span>
                                            </td>
                                            <td class="text-center">
                                                <button class="btn btn-xs btn-link"  ng-click="alertModal(list.id)"><i class="fa fa-search"></i> 查看</button>
                                                <button class="btn btn-xs btn-link" ng-if="list.status != 'Refund' && list.status != 'Refunded'" ng-click="editExpress(list.id, key)"><i class="fa fa-truck"></i> 发货</button>
                                                <button class="btn btn-xs btn-link" ng-if="list.status == 'Refund'" ng-click="setRefund(list.id, key)"><i class="fa fa-credit-card"></i> 退款</button>
                                            </td>
                                        </tr>
                                        <tr ng-if="lists && lists.length == 0">
                                            <td colspan="10" class="text-center text-muted">
                                                暂无订单
                                            </td>
                                        </tr>
                                    </table>
                                </div>

                                <div style="text-align: center; padding: 20px 0;" ng-show="nextPage">
                                    <button class="btn btn-link load-more" ng-click="loadMore()">加载更多</button>
                                </div>

                            </div>
                        </div>
                    </div>
                    <!-- /.tab-content -->
                </div>
                <!-- /.nav-tabs-custom -->
            </div>

        </div>
    </section>
    <!-- /.content -->

    <!--订单详情-->
    <div class="modal fade" id="orderDetail">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">订单详情</h4>
                </div>
                <div class="modal-body">
                    <!-- Main content -->
                    <section class="invoice">
                        <!-- title row -->
                        <div class="row">
                            <div class="col-xs-12">
                                <h2 class="page-header">
                                    <i class="fa fa-file-text"></i>
                                    <span ng-bind="'&nbsp;' + detail.sn + '.'" class="text-info"></span>
                                    <small class="pull-right" ng-bind="'下单时间: ' + detail.created"></small>
                                </h2>
                            </div>
                            <!-- /.col -->
                        </div>
                        <!-- info row -->
                        <div class="row invoice-info">
                            <div class="col-sm-4 invoice-col">
                                <address>
                                    <strong ng-bind="detail.addressInfo.name"></strong>
                                    <br>
                                    <br>
                                    地址: {{detail.addressInfo.address}}<br>
                                    详细地址: {{detail.addressInfo.area}}<br>
                                    电话: {{ detail.addressInfo.phone }}<br>
                                </address>
                            </div>
                            <div class="col-sm-4 invoice-col">
                                <b>支付信息</b><br>
                                <br>
                                <b>支付方式:&nbsp;&nbsp;</b> <span ng-bind="detail.payMode == 'online' ? '在线支付' : '货到付款'"></span><br>
                                <b>付款平台:&nbsp;&nbsp;</b> <span ng-bind="detail.payWay == 0 ? '未支付' : (detail.payWay == 1 ? '支付宝' : '微信')"></span><br>
                                <b>下单时间:&nbsp;&nbsp;</b> <span ng-bind="detail.created"></span>
                            </div>
                            <!-- /.col -->
                            <div class="col-sm-4 invoice-col">
                                <b>物流信息</b><br>
                                <br>
                                <b>快递单号:</b> {{ detail.distribution.expressNo }}<br>
                                <b>物流公司:</b> {{ detail.distribution.expressName }}<br>
                                <b>发货时间:</b> {{ detail.distribution.expressTime }}
                            </div>
                            <!-- /.col -->
                        </div>
                        <!-- /.row -->

                        <!-- Table row -->
                        <div class="row">
                            <div class="col-xs-12 table-responsive">
                                <table class="table table-striped">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>产品名称</th>
                                        <th class="text-center" >单价</th>
                                        <th class="text-center" >数量</th>
                                        <th class="text-center" >合计</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="g in detail.goods">
                                        <td ng-bind="g.goodsId"></td>
                                        <td ng-bind="g.goodsName"></td>
                                        <td class="text-center" ng-bind="'￥ ' + g.price"></td>
                                        <td class="text-center" ng-bind="g.num"></td>
                                        <td class="text-center" ng-bind="'￥ ' + g.itemTotal"></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.col -->
                        </div>
                        <!-- /.row -->

                        <div class="row">
                            <!-- accepted payments column -->
                            <div class="col-xs-7">
                                <p class="lead">买家留言:</p>

                                <p class="text-muted well well-sm no-shadow" style="margin-top: 10px;" ng-bind="!detail.message ? '无' : detail.message"></p>
                            </div>
                            <!-- /.col -->
                            <div class="col-xs-5">
                                <p class="lead">结算</p>

                                <div class="table-responsive">
                                    <table class="table">
                                        <tr>
                                            <th style="width:50%">商品金额:</th>
                                            <td class="text-right"><span ng-bind="'￥ ' + detail.goodsPrice"></span></td>
                                        </tr>
                                        <tr>
                                            <th>运费</th>
                                            <td class="text-right"><span ng-bind="'￥ ' + detail.expressPrice"></span></td>
                                        </tr>
                                        <tr>
                                            <th>代金券</th>
                                            <td class="text-right"><span ng-bind="'￥ ' + detail.voucherPrice"></span></td>
                                        </tr>
                                        <tr>
                                            <th>总计:</th>
                                            <td class="text-right"><span class="text-red" ng-bind="'￥ ' + detail.totalPrice"></span></td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                            <!-- /.col -->
                        </div>
                        <!-- /.row -->

                        <!-- this row will not appear when printing -->
                        <div class="row no-print">
                            <div class="col-xs-12">
                                <button type="button" class="btn btn-primary pull-left" style="margin-right: 5px;">
                                    <i class="fa fa-print"></i> 打印订单
                                </button>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </div>
    </div>
    <!-- /.modal -->

    <div class="modal fade" id="expressModal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">配送信息</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal">
                        <div class="callout callout-danger" ng-show="expError != ''">
                            <p ng-bind="expError"></p>
                        </div>
                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">选择物流</label>
                                <div class="col-sm-10">
                                    <div class="btn-group">
                                        <button type="button" class="btn btn-default btn-flat" ng-bind="defaultExp['expName']"></button>
                                        <button type="button" class="btn btn-default btn-flat dropdown-toggle" data-toggle="dropdown">
                                            <span class="caret"></span>
                                            <span class="sr-only">Toggle Dropdown</span>
                                        </button>
                                        <div style="display: inline-block; width: 105px; height: 33px; overflow: hidden; background: #000; margin-left: 15px;">
                                            <img style="margin:0; display: block; width: 105px; height: 33px;" ng-if="defaultExp['imgUrl'] != ''" ng-src="{{ defaultExp['imgUrl'] }}">
                                        </div>
                                        <ul class="dropdown-menu" role="menu">
                                            <li ng-repeat="($index, exp) in express"><a ng-click="selectExp($index)" ng-bind="exp.expName"></a></li>
                                        </ul>
                                    </div>
                                    <div class="express-info">
                                        <p style="font-size: 12px; color: #ccc; margin: 0;"><strong style="width: 55px; color: #aaa; display: inline-block;">网址:</strong> <a href="{{ defaultExp['url']}}">{{ defaultExp['url']}}</a> </p>
                                        <p style="font-size: 12px; margin: 0; color: #ccc;"><strong style="width: 55px; color: #aaa; display: inline-block;">联系电话:</strong> {{ defaultExp['phone']}} </p>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="expressNumber" class="col-sm-2 control-label">填写单号</label>

                                <div class="col-sm-8">
                                    <input type="text" class="form-control" id="expressNumber" ng-model="expSetting.expressNo" placeholder="填写单号">
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-md-12" style="border-bottom: 1px solid #eee;"></div>
                            </div>

                            <div class="form-group" ng-if="expressResult && expressResult.length > 0">
                                <label class="col-sm-2 control-label">物流信息</label>
                                <div class="col-sm-9">
                                    <div class="box-body no-padding">
                                        <table class="table table-striped" style="font-size: 12px;">
                                            <tr>
                                                <th style="width: 120px">日期</th>
                                                <th>跟踪记录</th>
                                            </tr>
                                            <tr ng-repeat="e in expressResult">
                                                <td ng-bind="e.time"></td>
                                                <td ng-bind="e.context"></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                            </div>
                            <div ng-if="!expressResult || expressResult.length == 0">
                                <p class="help-block text-center" style="">暂无查询结果</p>
                            </div>
                        </div>
                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" style="background: #00a65a; border: none;" ng-click="setExpress()">设置发货</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

    <div class="modal fade" id="refundModal">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">处理退款</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal">
                        <div class="callout callout-danger" ng-show="!!refundError && refundError != ''">
                            <p ng-bind="refundError"></p>
                        </div>

                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>产品名称</th>
                                <th class="text-center" style="width: 70px;">规格</th>
                                <th class="text-center" style="width: 90px;">成交单价</th>
                                <th class="text-center" style="width: 60px;">数量</th>
                                <th class="text-center" style="width: 60px;">总计</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr ng-repeat="g in detail.goods">
                                <td ng-bind="g.goodsId"></td>
                                <td ng-bind="g.goodsName"></td>
                                <td class="text-center" ng-bind="g.ruleName"></td>
                                <td class="text-center" ng-bind="'￥ ' + g.price"></td>
                                <td class="text-center" ng-bind="g.num"></td>
                                <td class="text-center" ng-bind="'￥ ' + g.itemTotal"></td>
                            </tr>
                            </tbody>
                        </table>

                        <br>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">成交金额:</label>
                            <div class="col-sm-10">
                                <p class="form-control-static" ng-bind="'￥ ' + detail.totalPrice + '（商品: ￥' + detail.goodsPrice + ' + 物流: ￥' + detail.expressPrice + '）'"></p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">够买时间:</label>
                            <div class="col-sm-10">
                                <p class="form-control-static" ng-bind="detail.created"></p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">退款金额</label>
                            <div class="col-sm-10">
                                <table class="table">
                                    <tr>
                                        <td style="width: 100px; cursor: pointer;" ng-click="selectRefund(1)">
                                            <i class="fa" ng-class="{'fa-dot-circle-o': refund.type == 1, 'text-green': refund.type == 1, 'fa-circle-o': refund.type != 1}"></i> &nbsp;
                                            全额退款
                                        </td>
                                        <td style="width: 160px;">

                                        </td>
                                        <td>
                                            全部商品金额退还到用户可支配账户（不含邮费）
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; cursor: pointer;" ng-click="selectRefund(2)">
                                            <i class="fa" ng-class="{'fa-dot-circle-o': refund.type == 2, 'text-green': refund.type == 2, 'fa-circle-o': refund.type != 2}"></i> &nbsp;
                                            活动退款
                                        </td>
                                        <td style="width: 160px;">

                                        </td>
                                        <td>
                                            退款70%到可支配账户,剩余30%只允许消费
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="cursor: pointer; border-bottom: 1px solid #f4f4f4;" ng-click="selectRefund(3)">
                                            <i class="fa" ng-class="{'fa-dot-circle-o': refund.type == 3, 'text-green': refund.type == 3, 'fa-circle-o': refund.type != 3}"></i> &nbsp;
                                            指定金额
                                        </td>
                                        <td style="border-bottom: 1px solid #f4f4f4;">
                                            <div class="input-group margin" style="width: 107px; margin: 0;">
                                                <input type="text" ng-model="refund.amount_cny" class="form-control" placeholder="0.00">
                                                    <span class="input-group-btn">
                                                        <button type="button" class="btn btn-default btn-flat">元</button>
                                                    </span>
                                            </div>
                                        </td>
                                        <td style="border-bottom: 1px solid #f4f4f4;">
                                            指定金额到用户个人账户
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" style="background: #00a65a; border: none;" ng-click="confirmRefund()">确认退款</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
</div>

<!-- /.content-wrapper -->
<?php $this->load->view('admin/public/foot.html', array('js' => array(
'/assets/admin/js/order/index.js'
))); ?>

